package auth_model

import "time"

// Role 角色模型
type Role struct {
	ID          uint64       `gorm:"primaryKey;autoIncrement" json:"id"`
	Name        string       `gorm:"type:varchar(64);not null" json:"name"`
	Code        string       `gorm:"type:varchar(64);uniqueIndex;not null" json:"code"`
	Description string       `gorm:"type:varchar(255)" json:"description"`
	Status      int8         `gorm:"type:tinyint(1);default:1" json:"status"` // 0=禁用 1=启用
	Permissions []Permission `gorm:"many2many:role_permissions" json:"permissions"`
	Menus       []Menu       `gorm:"many2many:role_menus" json:"menus"`
	CreatedAt   time.Time    `gorm:"autoCreateTime" json:"created_at"`
	UpdatedAt   time.Time    `gorm:"autoUpdateTime" json:"updated_at"`
}

// TableName 指定角色表名
func (Role) TableName() string {
	return "roles"
}
